import React from 'react';
import { querycandidatesbytalent } from '@/services/myRecruit/talentPool';

const useTalentTable = query => {
    const [data, setData] = React.useState([]);
    const [loading, setLoading] = React.useState(true);

    const fetchData = async () => {
        setLoading(true);
        const response = await querycandidatesbytalent({ talentCode: query.code });
        if (response && response.code === 10000) {
            setData(response.data);
        }
        setLoading(false);
    };

    React.useEffect(() => {
        fetchData();
    }, [query.code]);

    return [loading, data];
};

export default useTalentTable;
